<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CheckOutBook.ascx.cs" Inherits="CheckOutBook" %>
<%@ Register assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>
<style type="text/css">
    .style1
    {
        width: 100%;
    }
    .style2
    {
    }
    .style3
    {
        width: 220px;
    }
    .style4
    {
        width: 100px;
    }
    .style5
    {
        width: 106px;
    }
</style>
<h3>Check out book</h3>

<asp:Label ID="lblDate" runat="server"  Visible="false"></asp:Label>

<table class="style1">
    <tr>
        <td class="style4">
            <asp:Label ID="lblPatronId" runat="server" Text="Patron Id: "></asp:Label>
        </td>
        <td class="style3">
        
            <%--text box to enter patron's id--%>
            <asp:TextBox ID="txtPatronId" runat="server" Width="200px" OnTextChanged="txtPatronId_txtChange"></asp:TextBox>
        </td>
        <td class="style5">
        
            <%--button to select patron--%>
            <asp:Button ID="btnSearchPatron" runat="server" Text="Search" 
                onclick="btnSearchPatron_Click" TabIndex="1" />
        </td>
        <td rowspan="5" nowrap="nowrap">
            <%--displays patron's info for verification--%>
            <asp:DataList ID="DataList_Patron" runat="server" 
                DataSourceID="SqlDataSource_patron" ShowFooter="False" ShowHeader="False">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("FirstName") %>'></asp:Label>
                    &nbsp;<asp:Label ID="Label2" runat="server" Text='<%# Eval("LastName") %>'></asp:Label><br />
                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("Address") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label4" runat="server" 
                        Text='<%# Eval("PhoneNumber") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label6" runat="server" Text="Fines: "></asp:Label>
                    <asp:Label ID="Label5" runat="server" Text='<%# Eval("Fines") %>'></asp:Label>
                    <br />
                    <asp:CheckBox ID="CheckBox1" Text="Is Adult" runat="server" 
                        Checked='<%# Eval("isAdult") %>' Enabled="False" />
                </ItemTemplate>
            </asp:DataList>
        </td>
    </tr>
    <tr>
        <td class="style4">
            <asp:Label ID="lblBarcode" runat="server" Text="Barcode: "></asp:Label>
        </td>
        <td class="style3">
        
            <%--text box to enter barcode--%>
            <asp:TextBox ID="txtBarcode" runat="server" Width="200px" TabIndex="2"></asp:TextBox>
        </td>
        <td class="style5">
            <%--button to add book to checkout list--%>
            <asp:Button ID="btnBarcode" runat="server" Text="Add" 
                onclick="btnBarcode_Click" TabIndex="3" />
        </td>
    </tr>
    <tr>
        <td class="style4">
            &nbsp;</td>
        <td class="style3">
            <asp:Label ID="lblErrorMsg" runat="server" ForeColor="Red"></asp:Label>
        </td>
        <td class="style5">
            <asp:Button ID="Button1" runat="server" Text="Clear" onclick="Button1_Click" 
                TabIndex="4" />
        </td>
    </tr>
    <tr>
        <td class="style4">
            &nbsp;</td>
        <td class="style3">
            &nbsp;</td>
        <td class="style5">
            &nbsp;</td>
    </tr>
    <tr>
        <td class="style4">
            &nbsp;</td>
        <td class="style3">
            &nbsp;</td>
        <td class="style5">
            &nbsp;</td>
    </tr>
    <tr>
        <td class="style4">
            &nbsp;</td>
        <td class="style3">
            &nbsp;</td>
        <td class="style5">
            &nbsp;</td>
        <td>
            &nbsp;</td>
    </tr>
    <tr>
        <td class="style2" colspan="4">
        
            <%--displays a list of books being checked out--%>
            <%--<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource_Grid">
                <ItemTemplate>
                    <asp:Label ID="Label7" runat="server" Text='<%# Eval("Barcode") %>'></asp:Label>
                    <asp:Label ID="Label8" runat="server" Text='<%# Eval("Title") %>'></asp:Label>
                </ItemTemplate>
                <HeaderTemplate>
                    <asp:Label ID="Label9" runat="server" Text="Barcode"></asp:Label>
                    <asp:Label ID="Label10" runat="server" Text="Title"></asp:Label>
                </HeaderTemplate>
            </asp:DataList>--%>
            <asp:GridView ID="GridView_CheckedOutBooks" runat="server" AllowPaging="True" 
                AutoGenerateColumns="False" DataSourceID="SqlDataSource_Grid" 
                onselectedindexchanged="GridView1_SelectedIndexChanged">
                <Columns>
                    <asp:BoundField DataField="Barcode" HeaderText="Barcode" 
                        SortExpression="Barcode" />
                    <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                </Columns>
            </asp:GridView>
        </td>
    </tr>
    <tr>
        <td class="style4">
            &nbsp;</td>
        <td class="style3">
            &nbsp;</td>
        <td class="style5">
            &nbsp;</td>
        <td>
            &nbsp;</td>
    </tr>
</table>
<br />
<asp:SqlDataSource ID="SqlDataSource_patron" runat="server" OnSelected="SqlDataSource_patron_Selected"
    ConnectionString="<%$ ConnectionStrings:BPI_LibraryConnectionString %>" 
    SelectCommand="usp_PERSON_FindPersonPatronById" 
    SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:ControlParameter ControlID="txtPatronId" Name="PersonID" 
            PropertyName="Text" Type="String" />
    </SelectParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource_Grid" runat="server" 
    ConnectionString="<%$ ConnectionStrings:BPI_LibraryConnectionString %>" 
    SelectCommand="usp_BOOK_CheckOutBooks_Grid" SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:ControlParameter ControlID="txtPatronId" Name="PersonId" 
            PropertyName="Text" Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>
<br />

<asp:Button ID="btnReport" runat="server" Text="Checked Out Books Receipt" 
    onclick="btnReport_Click" />

<asp:Panel ID="pnlReport" runat="server" Visible="false">
    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
        AutoDataBind="True" Height="500px" Width="500px" PageZoomFactor="90" 
        DisplayGroupTree="False" />
    <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
        <Report FileName="Reports\CR_LibrarianCheckedOutBooksReceipt.rpt">
        </Report>
    </CR:CrystalReportSource>
</asp:Panel>



